
Page({
  data: {
    searchContent: "",
    iconUrl:'../../image/docs.png',
    queUrl: '../../image/que.png',
    searchUrl: "../../image/search.png",
    isShow: [],
    typearray:[],
    typeId:"",
    que:[],
    showIndex:-1
  },
  onLoad: function () {
    this.getAllTypes();
  },
  searchInput: function (e) {
    this.setData({
      searchContent: e.detail.value
    })
  },
  search: function () {
    if (this.data.searchContent != "") {
      wx.navigateTo({
        url: '../searchKnowledge/searchKnowledge?searchContent=' + this.data.searchContent
      })
    }
  },
  show:function(e){
    var index = e.currentTarget.dataset.index
    var that = this
    var typeName = e.currentTarget.dataset.typeName
    wx.request({
      url: 'https://eis.natappvip.cc/ITSupport/knowledge_getKnowledgessByType.action',
      data: {
        'type.typeName':typeName
      },
      header: {
        'Content-Type': 'application/json'
      },
      success: function (res) {
        let jsonresult = JSON.parse(res.data)
        console.log(jsonresult.result)
        if (jsonresult.result == "success") {
          that.setData({
            que: jsonresult.knowledges,
            showIndex: index,
          })
        }else{
          that.setData({
            showIndex: -1,
          })
        }
      },
      fail: function (res) {
        console.log("failed:" & res)
      }
    })
  },

  detail:function(e){
    var knowledgeId = e.currentTarget.dataset.knowledgeId
    wx.navigateTo({
      url: '../knowledgeDetail/knowledgeDetail?knowledgeId=' + knowledgeId
    })
  },

  getAllTypes: function () {
    var that = this
    wx.request({
      url: 'https://eis.natappvip.cc/ITSupport/type_getAllTypes.action',
      data: {},
      header: {
        'Content-Type': 'application/json'
      },
      success: function (res) {
        let jsonresult = JSON.parse(res.data)
        console.log(jsonresult.result)
        if (jsonresult.result == "success"){
          that.setData({
            typearray: jsonresult.types,
          })
        }
      },
      fail: function (res) {
        console.log("failed:" & res)
      }
    })
  },

  
})
